{% extends "bootstrap/base.html" %}

{% block title %}BBblog{% endblock %}

{% block head %}
{{ super() }}
<meta name="baidu-site-verification" content="code-ihY10yDFbA" />
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon">
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='styles.css') }}">
{% endblock %}

{% block navbar %}
<div class="navbar navbar-inverse" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="{{ url_for('main.index') }}">BBblog</a>
        </div>
        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <li><a href="{{ url_for('main.all_posttype') }}">归档</a></li>
                {% if current_user.can(Permission.WRITE_ARTICLES) or current_user.can(Permission.ADMINISTER) %}
                <li><a href="{{ url_for('main.new_post') }}">撰写博客</a></li>
                {% endif %}
            </ul>
            <ul class="nav navbar-nav navbar-right">
                {% if current_user.is_authenticated %}
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        账户 <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu">
                        {% if current_user.is_authenticated %}
                        <li><a href="{{ url_for('main.user', username=current_user.username) }}">个人资料</a></li>
                        {% endif %}
                        <li><a href="{{ url_for('auth.change_password') }}">修改密码</a></li>
                        <li><a href="{{ url_for('auth.change_email_request') }}">修改邮箱</a></li>
                        <li><a href="{{ url_for('auth.logout') }}">登出</a></li>
                    </ul>
                </li>
                {% else %}
                <li><a href="{{ url_for('auth.login') }}">登入</a></li>
                {% endif %}
            </ul>
            {% if searchform %}
            <form method="post" action="{{ url_for('.index') }}" class=" nav navbar-form navbar-right">
                <div class="form-group">
                    {{ searchform.hidden_tag() }}
                    <!-- 这个hidden_tag() 必须加上，不然提交不了 -->
                    {{ searchform.content(class_='form-control',placeholder_='输入博文内容或者标题') }}
                    <!-- <input type="text" class="form-control" placeholder="输入博文内容或者标题"> -->
                </div>
                <button id="submit" name="submit" type="submit" class="btn btn-default">搜索</button>
            </form>
            {% endif %}


        </div>

    </div>
</div>
{% endblock %}

{% block content %}
<div class="container">
    {% for message in get_flashed_messages() %}
    <div class="alert alert-warning">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        {{ message }}
    </div>
    {% endfor %}
    <div class="ztree" id="tree-toc" style="position: fixed;top: 100px;">
    </div>
    {% block page_content %}
    <link rel="stylesheet" href="{{ url_for('static',filename='editormd/css/editormd.css') }}" />
    <div class="row">
        <h1 class="text-center">编辑博文</h1>

        <form method="post" action="{{ url_for('.edit',id=post.id) }}" onsubmit="return confirm('确定要修改吗？')">
            {{ form.hidden_tag() }}
            <div class="form-group">
                {{ form.title.label }}
                {% if form.title.errors %}
                {% for e in form.title.errors %}
                <p class="help-block">{{ e }}</p>
                {% endfor %}
                {% endif %}
                {{ form.title(class_='form-control') }}
            </div>
            <div class="form-group">
                {{ form.posttype(class_='form-control',value_=form.posttype_id) }}
            </div>
            <div class="form-group">
                {{ form.content.label }}
                {% if form.content.errors %}
                {% for e in form.content.errors %}
                <p class="help-block">{{ e }}</p>
                {% endfor %}
                {% endif %}
                <div id="editormdtest" class="form-control">
                    {{ form.content(style="display:none;") }}
                </div>
            </div>
            <div class="text-center" style="margin-top:50px">
                <input class="btn btn-primary" type="submit" value="修改">
            </div>
        </form>
    </div>
    {% endblock %}
</div>

{% endblock %}

{% block scripts %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script>
<script type="text/javascript" src="https://pandao.github.io/dist/js/planeui.js"></script>
<script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
<script src="{{ url_for('static',filename='editormd/editormd.min.js') }}"></script>
<script type="text/javascript">
    var testEditor;

    $(function () {
        testEditor = editormd("editormdtest", {
            width: "100%",
            height: "640px",
            syncScrolling: "single",
            path: "{{ url_for('static',filename='editormd/lib/') }}",
            // saveHTMLToTextarea: true
        });
    });
</script>
{{ super() }}
{{ moment.include_moment() }}
{{ moment.lang('zh-CN') }}
{% endblock %}